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

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

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

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

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

i = A("i")
f = B("f")
g = C("g")
l = D("l")
j = E("j")
n = C("n")
m = B("m")

i.r = g
i.u = j
f.r = g
g.q = n
l.x = f
j.z = m
j.x = n
j.r = g
n.q = g
m.r = g
assert g.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: E = None
        self.txt = txt

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

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

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

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

i = A("i")
f = B("f")
g = C("g")
l = D("l")
j = E("j")
n = C("n")
m = B("m")

i.r = g
i.u = j
f.r = g
g.q = n
l.x = f
j.z = m
j.x = n
j.r = g
n.q = g
m.r = g
assert g.q.q.q.q.txt == "g"