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

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

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

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

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

b.u = j
b.x = j
n.s = k
k.y = n
k.o = c
k.q = f
k.w = b
j.x = b
c.s = k
f.u = j
f.x = j
i.s = k
assert n.s.y.s.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

b.u = j
b.x = j
n.s = k
k.y = n
k.o = c
k.q = f
k.w = b
j.x = b
c.s = k
f.u = j
f.x = j
i.s = k
assert n.s.y.s.w.x.txt == "j"