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

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

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

e = A("e")
g = B("g")
n = C("n")
c = B("c")
d = B("d")
m = B("m")

e.o = d
e.r = n
e.x = g
g.x = c
n.z = e
n.s = m
n.t = d
c.x = g
d.x = g
m.x = g
assert m.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
n = C("n")
c = B("c")
d = B("d")
m = B("m")

e.o = d
e.r = n
e.x = g
g.x = c
n.z = e
n.s = m
n.t = d
c.x = g
d.x = g
m.x = g
assert m.x.x.x.x.txt == "c"