class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: F = None
        self.x: E = None
        self.t: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.t: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

d = A("d")
h = B("h")
n = C("n")
g = D("g")
l = E("l")
j = F("j")

d.u = h
d.z = j
d.t = j
d.x = l
h.o = d
n.u = g
g.x = d
g.u = n
g.w = h
l.u = h
l.r = d
l.t = d
j.z = h
assert l.u.o.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: F = None
        self.x: E = None
        self.t: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.t: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

d = A("d")
h = B("h")
n = C("n")
g = D("g")
l = E("l")
j = F("j")

d.u = h
d.z = j
d.t = j
d.x = l
h.o = d
n.u = g
g.x = d
g.u = n
g.w = h
l.u = h
l.r = d
l.t = d
j.z = h
assert l.u.o.x.r.txt == "d"