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

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

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

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

n = A("n")
c = B("c")
d = C("d")
j = D("j")
g = A("g")
f = D("f")

n.x = d
n.o = j
c.r = d
c.o = f
c.v = g
d.u = c
j.y = n
j.w = d
g.x = d
g.o = j
f.y = n
f.w = d
assert n.x.u.v.o.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: D = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
d = C("d")
j = D("j")
g = A("g")
f = D("f")

n.x = d
n.o = j
c.r = d
c.o = f
c.v = g
d.u = c
j.y = n
j.w = d
g.x = d
g.o = j
f.y = n
f.w = d
assert n.x.u.v.o.w.u.txt == "c"