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

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

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

b = A("b")
k = B("k")
m = C("m")
f = B("f")
h = B("h")
c = A("c")
j = B("j")
i = C("i")
l = C("l")

b.q = h
b.x = f
k.t = b
m.x = h
m.q = b
m.r = b
f.t = b
h.t = b
c.q = k
c.x = h
j.t = b
i.x = f
i.q = b
i.r = c
l.x = h
l.q = c
l.r = c
assert k.t.q.t.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
m = C("m")
f = B("f")
h = B("h")
c = A("c")
j = B("j")
i = C("i")
l = C("l")

b.q = h
b.x = f
k.t = b
m.x = h
m.q = b
m.r = b
f.t = b
h.t = b
c.q = k
c.x = h
j.t = b
i.x = f
i.q = b
i.r = c
l.x = h
l.q = c
l.r = c
assert k.t.q.t.x.t.x.txt == "f"