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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.u: A = None
        self.r: A = None
        self.y: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
h = C("h")
e = D("e")
a = E("a")
i = B("i")

c.r = i
c.t = a
g.s = c
g.u = c
g.r = c
g.t = i
g.y = e
h.z = c
e.r = g
a.q = c
i.s = c
i.u = c
i.r = c
i.t = g
i.y = e
assert a.q.t.q.r.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.u: A = None
        self.r: A = None
        self.y: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
h = C("h")
e = D("e")
a = E("a")
i = B("i")

c.r = i
c.t = a
g.s = c
g.u = c
g.r = c
g.t = i
g.y = e
h.z = c
e.r = g
a.q = c
i.s = c
i.u = c
i.r = c
i.t = g
i.y = e
assert a.q.t.q.r.t.u.txt == "c"