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

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

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

g = A("g")
e = B("e")
c = C("c")
h = B("h")
j = B("j")
l = A("l")

g.r = l
e.u = c
e.o = l
e.z = l
c.s = l
c.o = g
h.u = c
h.o = l
h.z = l
j.u = c
j.o = l
j.z = l
l.r = g
assert j.z.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
c = C("c")
h = B("h")
j = B("j")
l = A("l")

g.r = l
e.u = c
e.o = l
e.z = l
c.s = l
c.o = g
h.u = c
h.o = l
h.z = l
j.u = c
j.o = l
j.z = l
l.r = g
assert j.z.r.r.r.txt == "g"