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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: A = None
        self.w: C = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

f.q = c
e.s = h
e.v = h
e.q = g
e.t = g
e.w = c
c.u = n
h.r = n
j.y = f
j.p = c
j.r = g
n.r = h
l.y = f
l.p = c
l.r = g
g.q = c
m.s = n
m.q = g
m.t = g
m.w = c
m.v = h
i.s = n
i.v = n
i.q = f
i.t = f
i.w = c
assert h.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: A = None
        self.w: C = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

f.q = c
e.s = h
e.v = h
e.q = g
e.t = g
e.w = c
c.u = n
h.r = n
j.y = f
j.p = c
j.r = g
n.r = h
l.y = f
l.p = c
l.r = g
g.q = c
m.s = n
m.q = g
m.t = g
m.w = c
m.v = h
i.s = n
i.v = n
i.q = f
i.t = f
i.w = c
assert h.r.r.r.txt == "n"