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

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

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

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

j = A("j")
g = B("g")
k = C("k")
h = D("h")
m = B("m")

j.x = k
j.v = m
g.y = k
g.z = k
g.t = k
k.x = j
h.v = k
h.u = k
h.p = j
m.y = k
m.z = k
m.t = k
assert m.y.x.v.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
k = C("k")
h = D("h")
m = B("m")

j.x = k
j.v = m
g.y = k
g.z = k
g.t = k
k.x = j
h.v = k
h.u = k
h.p = j
m.y = k
m.z = k
m.t = k
assert m.y.x.v.t.x.txt == "j"