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

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

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

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

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

b.s = h
b.v = f
h.u = j
f.z = h
f.q = b
f.y = b
f.x = k
j.w = b
j.y = b
c.u = j
k.w = b
k.y = b
assert h.u.w.v.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: C = None
        self.txt = txt

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

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

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

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

b.s = h
b.v = f
h.u = j
f.z = h
f.q = b
f.y = b
f.x = k
j.w = b
j.y = b
c.u = j
k.w = b
k.y = b
assert h.u.w.v.x.w.txt == "b"