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

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

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

i = A("i")
k = B("k")
g = C("g")
b = B("b")
e = C("e")

i.u = b
i.t = b
i.p = k
k.o = e
g.x = i
g.q = e
b.o = g
e.x = i
e.q = g
assert k.o.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.p: B = None
        self.txt = txt

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

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

i = A("i")
k = B("k")
g = C("g")
b = B("b")
e = C("e")

i.u = b
i.t = b
i.p = k
k.o = e
g.x = i
g.q = e
b.o = g
e.x = i
e.q = g
assert k.o.x.u.txt == "b"