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

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

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

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

b = A("b")
a = B("a")
h = C("h")
l = D("l")
g = B("g")

b.o = h
b.t = l
a.r = g
a.u = l
a.x = h
h.w = l
h.q = l
l.v = b
l.u = a
g.r = a
g.u = l
g.x = h
assert a.x.w.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: D = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
h = C("h")
l = D("l")
g = B("g")

b.o = h
b.t = l
a.r = g
a.u = l
a.x = h
h.w = l
h.q = l
l.v = b
l.u = a
g.r = a
g.u = l
g.x = h
assert a.x.w.u.r.txt == "g"