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

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

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

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

l = A("l")
k = B("k")
j = C("j")
b = D("b")
d = B("d")
m = A("m")

l.s = b
k.q = d
k.r = d
j.v = l
j.s = m
j.t = b
b.y = m
d.q = k
d.r = k
m.s = b
assert k.r.q.r.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
j = C("j")
b = D("b")
d = B("d")
m = A("m")

l.s = b
k.q = d
k.r = d
j.v = l
j.s = m
j.t = b
b.y = m
d.q = k
d.r = k
m.s = b
assert k.r.q.r.q.q.r.txt == "k"