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

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

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

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

b = A("b")
l = B("l")
a = C("a")
e = D("e")
j = A("j")
k = D("k")
c = B("c")

b.t = j
l.v = c
l.r = c
l.q = k
l.w = b
a.r = j
a.s = b
e.p = k
j.t = b
k.p = e
c.v = l
c.r = l
c.q = e
c.w = j
assert k.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
a = C("a")
e = D("e")
j = A("j")
k = D("k")
c = B("c")

b.t = j
l.v = c
l.r = c
l.q = k
l.w = b
a.r = j
a.s = b
e.p = k
j.t = b
k.p = e
c.v = l
c.r = l
c.q = e
c.w = j
assert k.p.p.p.p.p.txt == "e"