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

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

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

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

j = A("j")
h = B("h")
d = C("d")
a = D("a")

j.p = d
j.y = a
h.t = j
d.r = h
d.t = j
d.w = a
a.q = h
a.r = d
a.u = j
assert a.u.y.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: D = None
        self.txt = txt

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

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

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

j = A("j")
h = B("h")
d = C("d")
a = D("a")

j.p = d
j.y = a
h.t = j
d.r = h
d.t = j
d.w = a
a.q = h
a.r = d
a.u = j
assert a.u.y.q.t.txt == "j"