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

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

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

d = A("d")
j = B("j")
b = C("b")
e = B("e")
c = C("c")
f = C("f")
n = B("n")
k = A("k")

d.y = k
d.x = k
d.o = k
j.x = c
j.v = f
b.w = d
e.x = c
e.v = b
c.w = d
f.w = d
n.x = f
n.v = c
k.y = d
k.x = d
k.o = d
assert e.x.w.o.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
b = C("b")
e = B("e")
c = C("c")
f = C("f")
n = B("n")
k = A("k")

d.y = k
d.x = k
d.o = k
j.x = c
j.v = f
b.w = d
e.x = c
e.v = b
c.w = d
f.w = d
n.x = f
n.v = c
k.y = d
k.x = d
k.o = d
assert e.x.w.o.y.x.y.txt == "d"