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

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

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

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

j = A("j")
b = B("b")
k = C("k")
l = D("l")
c = C("c")
f = C("f")
h = D("h")

j.r = h
j.w = h
j.q = f
j.s = l
b.p = j
k.q = h
l.t = c
c.q = h
f.q = h
h.t = k
assert b.p.w.t.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.q: C = None
        self.s: D = None
        self.w: D = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
k = C("k")
l = D("l")
c = C("c")
f = C("f")
h = D("h")

j.r = h
j.w = h
j.q = f
j.s = l
b.p = j
k.q = h
l.t = c
c.q = h
f.q = h
h.t = k
assert b.p.w.t.q.t.q.txt == "h"