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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: E = None
        self.s: B = None
        self.t: C = None
        self.txt = txt

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

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

c.x = i
j.t = i
j.w = g
j.x = a
j.v = b
j.o = c
b.t = d
i.q = a
i.p = a
i.s = j
i.t = b
e.r = b
d.t = b
g.r = b
a.r = b
f.r = d
assert j.w.r.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: E = None
        self.s: B = None
        self.t: C = None
        self.txt = txt

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

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

c.x = i
j.t = i
j.w = g
j.x = a
j.v = b
j.o = c
b.t = d
i.q = a
i.p = a
i.s = j
i.t = b
e.r = b
d.t = b
g.r = b
a.r = b
f.r = d
assert j.w.r.t.t.t.t.t.t.t.txt == "d"