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

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

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

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

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

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

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

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

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

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

c.r = b
d.r = c
d.o = g
d.u = b
d.s = i
b.u = c
b.y = c
b.x = g
b.w = d
g.y = b
g.v = i
g.q = c
j.r = b
i.r = c
i.o = g
i.u = b
i.s = d
assert b.w.r.r.w.u.txt == "b"