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

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

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

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

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

k.y = d
d.t = l
d.p = h
h.p = d
h.y = j
j.w = d
j.v = h
l.y = d
c.w = d
c.v = h
assert c.v.p.p.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

k.y = d
d.t = l
d.p = h
h.p = d
h.y = j
j.w = d
j.v = h
l.y = d
c.w = d
c.v = h
assert c.v.p.p.y.v.y.txt == "j"