class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

n = A("n")
g = B("g")
e = C("e")
j = B("j")

n.u = e
g.p = n
g.x = n
e.o = n
j.p = n
j.x = n
assert g.p.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

n = A("n")
g = B("g")
e = C("e")
j = B("j")

n.u = e
g.p = n
g.x = n
e.o = n
j.p = n
j.x = n
assert g.p.u.o.u.txt == "e"