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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: E = None
        self.q: B = None
        self.txt = txt

g = A("g")
c = B("c")
f = C("f")
e = D("e")
a = E("a")
m = D("m")
d = B("d")
b = B("b")
i = E("i")

g.r = f
g.t = b
g.v = b
g.q = a
c.q = m
c.r = d
f.x = m
e.w = m
e.r = c
e.q = f
a.y = i
a.q = d
m.w = e
m.r = b
m.q = f
d.q = m
d.r = b
b.q = e
b.r = d
i.y = a
i.q = d
assert f.x.r.r.r.q.r.r.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: B = None
        self.q: E = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: E = None
        self.q: B = None
        self.txt = txt

g = A("g")
c = B("c")
f = C("f")
e = D("e")
a = E("a")
m = D("m")
d = B("d")
b = B("b")
i = E("i")

g.r = f
g.t = b
g.v = b
g.q = a
c.q = m
c.r = d
f.x = m
e.w = m
e.r = c
e.q = f
a.y = i
a.q = d
m.w = e
m.r = b
m.q = f
d.q = m
d.r = b
b.q = e
b.r = d
i.y = a
i.q = d
assert f.x.r.r.r.q.r.r.q.q.txt == "f"