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

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

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

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

d.x = h
d.q = f
k.w = d
f.t = h
f.o = b
g.w = e
h.t = f
h.o = b
b.t = h
b.o = f
e.x = h
e.q = f
assert d.x.o.t.o.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: C = None
        self.txt = txt

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

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

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

d.x = h
d.q = f
k.w = d
f.t = h
f.o = b
g.w = e
h.t = f
h.o = b
b.t = h
b.o = f
e.x = h
e.q = f
assert d.x.o.t.o.t.t.txt == "f"