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

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

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

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

d = A("d")
j = B("j")
h = C("h")
b = D("b")
g = D("g")

d.z = h
d.r = b
d.y = j
j.v = d
j.w = b
j.y = h
h.u = b
h.y = b
h.z = d
h.t = d
b.s = h
g.s = h
assert g.s.z.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: D = None
        self.y: B = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
h = C("h")
b = D("b")
g = D("g")

d.z = h
d.r = b
d.y = j
j.v = d
j.w = b
j.y = h
h.u = b
h.y = b
h.z = d
h.t = d
b.s = h
g.s = h
assert g.s.z.r.s.txt == "h"