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

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

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

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

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

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

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

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

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

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

l.s = b
l.t = b
l.r = a
g.t = j
g.u = a
g.s = a
g.w = l
a.o = g
a.s = j
j.v = a
b.s = l
b.t = l
b.r = a
assert g.t.v.s.v.txt == "a"