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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.txt = txt

k = A("k")
m = B("m")
e = C("e")
h = A("h")
b = A("b")
g = B("g")

k.x = h
k.p = e
m.y = h
m.u = e
e.t = m
e.x = m
h.x = k
h.p = e
b.x = k
b.p = e
g.y = b
g.u = e
assert e.x.y.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.txt = txt

k = A("k")
m = B("m")
e = C("e")
h = A("h")
b = A("b")
g = B("g")

k.x = h
k.p = e
m.y = h
m.u = e
e.t = m
e.x = m
h.x = k
h.p = e
b.x = k
b.p = e
g.y = b
g.u = e
assert e.x.y.x.p.txt == "e"